# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.
from django.utils.encoding import python_2_unicode_compatible

from pep.models import Worker_info
from prj.models import Detail_info

'''产品升级状态：改造中、已发布、已归档、不支持'''
@python_2_unicode_compatible
class Update_status_info(models.Model):
    update_status_name = models.CharField(max_length=32, verbose_name='产品升级状态')

    def __str__(self):
        return self.update_status_name

    class Meta:
        db_table = 'prd_update_status_info'
        verbose_name = '产品升级状态'
        verbose_name_plural = '产品状态'

'''产品升级归属年度：2016年、2017年'''
@python_2_unicode_compatible
class Year_plan_info(models.Model):
    year_plan_name = models.CharField(max_length=32, verbose_name='产品升级归属年度')

    def __str__(self):
        return self.year_plan_name

    class Meta:
        db_table = 'prd_year_plan_info'
        verbose_name = '产品升级归属年度'
        verbose_name_plural = '归属年度'

'''产品升级类型：计划内、计划外'''
@python_2_unicode_compatible
class Update_type_info(models.Model):
    update_type_name = models.CharField(max_length=32, verbose_name='产品升级类型')

    def __str__(self):
        return self.update_type_name

    class Meta:
        db_table = 'prd_update_type_info'
        verbose_name = '产品升级类型'
        verbose_name_plural = '升级类型'

'''升级任务状态：正常、延期、停滞、完成'''
@python_2_unicode_compatible
class Task_status_info(models.Model):
    task_status_name = models.CharField(max_length=32, verbose_name='升级任务状态')

    def __str__(self):
        return self.task_status_name

    class Meta:
        db_table = 'prd_task_status_info'
        verbose_name = '升级任务状态'
        verbose_name_plural = '任务状态'

'''产品升级信息'''
@python_2_unicode_compatible
class Update_info(models.Model):
    update_name = models.CharField(max_length=128, verbose_name='产品名称')
    update_version = models.CharField(max_length=32, verbose_name='当前版本')
    update_status_number = models.ForeignKey(Update_status_info, verbose_name='产品状态')
    year_plan_number = models.ForeignKey(Year_plan_info, verbose_name='归属年度')
    update_type_number = models.ForeignKey(Update_type_info, verbose_name='升级类型')
    update_s_date = models.DateField(verbose_name='升级开始日期')
    update_e_date = models.DateField(verbose_name='升级截止日期')
    update_coder_number = models.ForeignKey(Worker_info, verbose_name='升级负责人')
    task_status_number = models.ForeignKey(Task_status_info, verbose_name='升级任务状态')
    update_manager_number = models.ForeignKey(Worker_info, related_name='provider',verbose_name='产品负责人')
    project_info_number = models.ForeignKey(Detail_info, blank=True, verbose_name='研发项目')
    update_remark = models.TextField(blank=True, verbose_name='备注')

    def __str__(self):
        return self.update_name

    class Meta:
        db_table = 'prd_update_info'
        verbose_name = '产品升级信息'
        verbose_name_plural = '产品信息'